package saeildamil.ch21.bdconn;

import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

import javax.swing.JOptionPane;

public class JdbcEx01 {
	public static void main(String[] args) {
		Connection con=null;	
		try{
		Class.forName("com.mysql.jdbc.Driver");
		String url = "jdbc:mysql://localhost:3307//test";
		String user = "root";
		String password ="rootroot";
		
	    con = DriverManager.getConnection(url, user, password);
	    JOptionPane.showConfirmDialog(null, "데이터베이스 연결 성공");
		}catch (ClassNotFoundException e){
			System.out.println("해당하는 클래스를 찾을 수 없음");
		}catch(SQLException e){
			e.printStackTrace();
		}finally{
			try{con.close();}catch(Exception e){}
		}
	}
	private Connection dbCon(){
		Connection conn;
		File file = new File("dbinfo.com");
		try{
		BufferedReader bis = new BufferedReader(new FileReader(file));
		String url = bis.readLine();
		String url = bis.readLine();
		String user = bis.readLine();
		String password = bis.readLine();
		Class.forName(className);
	}catch(FileNotFoundException e){
		e.printStackTrace();
	}catch(IOException e){
		e.printStackTrace();
	}catch(ClassNotFoundException e){
		e.printStackTrace();
	}
		
		
		
		
		
}
